package com.elong.spring.proxy;

import java.lang.reflect.Proxy;

public class TestForumService {

    public static void main(String[] args) {
	ForumService forumService = new ForumServiceImpl();
	forumService.removeForum(10);
	forumService.removeTopic(1024);
	
	//采用代理模式
	ForumService target = new ForumServiceAOPImpl();
	
	PerformanceHandler handler = new PerformanceHandler(target);
	
	ForumService proxy = (ForumService) Proxy.newProxyInstance(target.getClass().getClassLoader(), target.getClass().getInterfaces(), handler);
	proxy.removeForum(10);
	proxy.removeTopic(1024);
	
	cglibTest();
    }
    
    public static void cglibTest(){
	CglibProxy proxy = new CglibProxy();
	ForumServiceAOPImpl forumService = (ForumServiceAOPImpl) proxy.getProxy(ForumServiceAOPImpl.class);
	forumService.removeForum(11);
	forumService.removeTopic(1023);
    }
}
